package com.service.edu.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.service.edu.listenter.ExcelSubjectReadListenter;
import com.service.edu.pojo.Subject;
import com.service.edu.mapper.SubjectMapper;
import com.service.edu.pojo.Teacher;
import com.service.edu.pojo.excel.SubjectData;
import com.service.edu.service.SubjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 课程科目 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-09-24
 */
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements SubjectService {

    @Override
    public List<Subject> getList() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("parent_id",0);
        List<Subject> list = list(queryWrapper);
        for (Subject subject : list) {
            queryWrapper = new QueryWrapper();
            queryWrapper.eq("parent_id",subject.getId());
            List<Subject> teachers = list(queryWrapper);
            subject.setChildren(teachers);
        }
        return list;

    }



}
